<script>
  const list = [
    { name: '张三', age: 18 },
    { name: '李四', age: 14 },
    { name: '王五', age: 12 }
  ]

  function transList(souceList,filterList) {
    const transList = souceList.map((item) => {
      console.log(item)
      const list = []
      // 找到对象的每一个值，再遍历
      Object.keys(item).forEach(key => {
        console.log(key)
        console.log(filterList.includes(key))
        if (filterList.includes(key)) {
          list.push(item[key])
          console.log(item[key])
        }
      })
      return list
    })
    console.log(transList)
    return transList
  }

  const _list = transList(list,['name'])
  console.log(_list)
</script>